<?php require_once('Connections/sepolwan_connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_cariblog = "-1";
if (isset($_GET['cari'])) {
  $colname_cariblog = $_GET['cari'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_cariblog = sprintf("SELECT * FROM artikel WHERE judul LIKE %s", GetSQLValueString("%" . $colname_cariblog . "%", "text"));
$cariblog = mysql_query($query_cariblog, $sepolwan_connect) or die(mysql_error());
$row_cariblog = mysql_fetch_assoc($cariblog);
$totalRows_cariblog = mysql_num_rows($cariblog);

$colname_caritimeline = "-1";
if (isset($_GET['cari'])) {
  $colname_caritimeline = $_GET['cari'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_caritimeline = sprintf("SELECT * FROM dinding_tl WHERE judul LIKE %s", GetSQLValueString("%" . $colname_caritimeline . "%", "text"));
$caritimeline = mysql_query($query_caritimeline, $sepolwan_connect) or die(mysql_error());
$row_caritimeline = mysql_fetch_assoc($caritimeline);
$totalRows_caritimeline = mysql_num_rows($caritimeline);

$colname_caripeople = "-1";
if (isset($_GET['cari'])) {
  $colname_caripeople = $_GET['cari'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_caripeople = sprintf("SELECT * FROM memberdb WHERE full_name LIKE %s", GetSQLValueString("%" . $colname_caripeople . "%", "text"));
$caripeople = mysql_query($query_caripeople, $sepolwan_connect) or die(mysql_error());
$row_caripeople = mysql_fetch_assoc($caripeople);
$totalRows_caripeople = mysql_num_rows($caripeople);
?>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="5"><div id="halaman"><div class="jusul">Pencarian " <?php echo $_GET['cari'] ?> "</div></td>
  </tr>
  <tr>
    <td colspan="5">&nbsp;</td>
  </tr>
  <tr>
    <td width="310" valign="top"><div id="halaman"><strong>Search on blog</strong><br />
        <?php do { ?>
          <div style="padding-bottom:5px; padding-top:5px; border-bottom:1px solid #CCC"><a href="<?php echo $base ?>detail-<?php echo $row_cariblog['id']; ?>/<?php echo str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_cariblog['judul']); ?>.html"><?php echo $row_cariblog['judul']; ?></a></div>
          <?php } while ($row_cariblog = mysql_fetch_assoc($cariblog)); ?>
    </div></td>
    <td width="10">&nbsp;</td>
    <td width="310" valign="top"><div id="halaman"><strong>Search on timeline</strong><br />
        <?php do { 
if ($totalRows_caritimeline>0) {
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_people = "SELECT * FROM memberdb WHERE id = ".$row_caritimeline['me'];
$people = mysql_query($query_people, $sepolwan_connect) or die(mysql_error());
$row_people = mysql_fetch_assoc($people);
$totalRows_people = mysql_num_rows($people);
		?>
          <div style="padding-bottom:5px; padding-top:5px; border-bottom:1px solid #CCC"><a href="<?php echo $base ?><?php  if ($row_caritimeline['judul']<>"") {  
	echo $row_people['nama_user']."/artikel/".$row_caritimeline['id']."-".str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_caritimeline['judul']); 
	} else {
		echo $row_people['nama_user']."/artikel/".$row_caritimeline['id']."-post";
	}?>.html"><?php echo $row_caritimeline['judul']; ?></a></div>
          <?php mysql_free_result($people); } } while ($row_caritimeline = mysql_fetch_assoc($caritimeline)); ?>
    </div></td>
    <td width="10">&nbsp;</td>
    <td width="310" valign="top"><div id="halaman"><strong>Search on people</strong><br />
        <?php do { ?>
          <div style="padding-bottom:5px; padding-top:5px; border-bottom:1px solid #CCC"><a href="<?php echo $base.$row_caripeople['nama_user']; ?>"><?php echo $row_caripeople['full_name']; ?></a></div>
          <?php } while ($row_caripeople = mysql_fetch_assoc($caripeople)); ?>
    </div></td>
  </tr>
</table>
<?php
mysql_free_result($cariblog);

mysql_free_result($caritimeline);

mysql_free_result($caripeople);
?>
